define(function () {
    return function ($compile, $scope) {
        require(["PDUtilDir/util", "AppPathDir/group/guideGroupInfos/upload", "AppPathDir/group/guideGroupInfos/support",
            "AppPathDir/group/guideGroupInfos/detail", "AppPathDir/group/guideGroupInfos/pay", "PDUtilDir/inputSelect"], function (Util, UploadSupport, Support,
                                                                                                                                   DetailSupport, PaySupport, inputSelect) {
            /* 查询 start */
            $scope.search = {};
            $scope.cache = {
                status: new Array(),
                statusMap: new Map()
            };
            $scope.searchSupport = {
                run: function () {
                    $scope.grid.reload({
                        queryParam: {
                            model: JSON.stringify($scope.search)
                        }
                    })
                }
            };
            $.ajax({
                url: getServer() + "/flea/hclv/getPayType.htmls",
                success: function (data) {
                    if (data.status != 200) {
                        return;
                    }
                    $scope.cache.types = data.data;
                }
            });
            $scope.paySupport = PaySupport($scope, $compile);
            //上传报帐单
            $scope.uploadSupport = UploadSupport($scope, $compile);
            //报帐单详情
            $scope.detailSupport = DetailSupport($scope, $compile);
            //取消指派
            $scope.cancelSupport = {
                run: function (id) {
                    Util.confirm("确认取消指派？", function () {
                        $.ajax({
                            url: getServer() + "/flea/hclv/guide/cancelAssignGuide.htmls",
                            data: {
                                travelGroupId: id
                            },
                            success: function (data) {
                                if (data.status != 200) {
                                    return
                                }
                                Util.alert(data.message);
                                $scope.grid.refresh();
                            }
                        });
                    });
                }
            };

            $.ajax({
                url: getServer() + "/flea/hclv/getGuidePayStatus.htmls",
                success: function (data) {
                    $scope.cache.status = data.data;
                    $.each(data.data, function (index, row) {
                        $scope.cache.statusMap.set(row.dictCode, row.dictName);
                    });
                    // 初始化状态下拉框
                    inputSelect.dropCache();
                    inputSelect({
                        id: "groupStatus",
                        key: {
                            id: "dictCode",
                            name: "dictName",
                            data: "data",
                        },
                        data: $scope.cache.status,
                        simpleData: true,
                        searchAble: false,
                        callback: function (id) {
                            $scope.search.groupStatus = id[0];
                        }
                    });
                    $scope.grid = Support.init($scope.cache, $scope.searchSupport);
                }
            });
        })
    }
});